package com.ybkj.daijia.api.driver.v1;

import com.ybkj.daijia.server.service.AreaService;
import com.ybkj.daijia.server.service.ChargeStartTimeService;
import com.ybkj.daijia.server.service.CompanyService;
import com.ybkj.daijia.server.service.DriverService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping(value = "driver/api/rest/v1")
public class ChargeController {

    private static final Logger logger = LoggerFactory.getLogger(ChargeController.class);

    @Autowired
    private DriverService driverService;

    @Autowired
    private CompanyService companyService;

    @Autowired
    private AreaService areaService;

    @Autowired
    private ChargeStartTimeService chargeStartTimeService;

    /**
     * 查询该司机所在公司的收费标准
     *
     * @param id
     * @param longitude
     * @param latitude
     * @param appKey
     * @param token
     * @param timestamp
     * @return
     */
//	@RequestMapping(value = "charge")
//	public @ResponseBody ResultTransport charge(Long id, String appKey, String token, String timestamp) {
//
//		logger.debug("recv id:{},appKey:{},token:{},timestamp:{}",id, appKey, token, timestamp);
//
//		if (null == id|| SecurityUtils.isBlank(appKey, token, timestamp)) {
//			return ResultTransport.getErrorBy(ErrorConstant.PARAM_ERROR);
//		}
//
//		if (!StringUtils.isNumeric(timestamp)
//				|| !SecurityUtils.checkTimestamp(Long.parseLong(timestamp))) {
//			return ResultTransport.getErrorBy(ErrorConstant.TIMESTAMP_ERROR);
//		}
//
//		List<String> params = new LinkedList<String>();
//		params.add(String.valueOf(id));
//		params.add(timestamp);
//		params.add(appKey);
//
//		if (!SecurityUtils.checkToken(params, token)) {
//			return ResultTransport.getErrorBy(ErrorConstant.TOKEN_ERROR);
//		}
//
//		try {
//
//			Driver driver = driverService.findOne(id);
//
//			if (null == driver) {
//				return ResultTransport.getErrorBy(ErrorConstant.DRIVER_NOT_EXISTS);
//			}
//
//			Company company = companyService.findOne(driver.getCompanyId());
//			
//			if(null == company) {
//				return ResultTransport.getErrorBy(ErrorConstant.DRIVER_NO_COMPANY_ERROR);
//			}
//			
//			Area area = areaService.findOneWithCharge(company.getAreaId());
//			
//			if(null == area) {
//				return ResultTransport.getErrorBy(ErrorConstant.COMPANY_NO_AREA_ERROR);
//			}
//			
//			ResultTransport transport = ResultTransport.getErrorBy(ErrorConstant.SUCCESS);
//			transport.setData(area);
//
//			return transport;
//
//		} catch (Exception e) {
//			logger.error("api v1 driver modifyPass error: {}", e);
//			return ResultTransport.getErrorBy(ErrorConstant.SERVER_ERROR);
//		}
//
//	}
}
